$(function(){		
    $('.sf_admin_td_actions li a').click(function(event) {
		event.preventDefault();
		abrirModal($(this));
   });
});

function closeModal() {
    window.parent.$('#site').dialog('close');
    window.parent.$('#site').remove();
}

function abrirModal(inst){
    var horizontalPadding = 15;
    var verticalPadding = 15;
    $('body').css('overflow','hidden');
    var width = $(window).width();
    var height = $(window).height();
    $('<iframe id="site" src="' + inst.attr('href') + '" />').dialog({
        title: $("#site").contents().find("#sf_admin_container > h1").html(),
        autoOpen: true,
        width: width,
        height: height,
        modal: true,
        resizable: false,
        autoResize: true,
        stack: true,
        draggable: false,
        overlay: {
            opacity: 0.5,
            background: "black"
        },
        beforeClose: function(event, ui) {
            var record_save = $('#site').contents().find('.notice').length > 0;
            $('#site').remove();
            $('body').css('overflow','scroll');
            if (record_save){
                location.reload();
            }
        }
    }).width(width - horizontalPadding).height(height - verticalPadding - 30);
    
}